package com.panda.git;

import com.panda.common.ResourceHolder;
import com.panda.pojo.Context;
import com.panda.pojo.Pr;
import com.panda.utils.PrePostUtils;

/*

    打包器

    打包器和编译器是相似,不同点在于前者只将服务和

 */
public class Packetizer {

    private ResourceHolder resourceHolder;

    public Packetizer(ResourceHolder resourceHolder) {
        this.resourceHolder = resourceHolder;
    }

    public void packet(String group, String root, String version) {

        try {
            resourceHolder.handle();
        } catch (Exception e) {
            throw new RuntimeException(e);
        }

        Context context = new Context();

        context.setConfig(resourceHolder.getConfig());

        PrePostUtils.pre(context, resourceHolder);

        if (!PushUtils.push(group, root, version, context)) {
            throw new RuntimeException("打包失败");
        }

    }

}
